package common;

import com.jfinal.config.*;
import com.jfinal.core.JFinal;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;
import controller.LoginController;
import controller.Maincontroller;
import controller.RegController;
import controller.ShowDetial;

/**
 * Created by XingYang on 2018/5/8.
 */
public class MainConfig extends JFinalConfig{
    @Override
    public void configConstant(Constants constants) {
        constants.setDevMode(true);

    }

    @Override
    public void configRoute(Routes routes) {
      //  routes.setViewType(ViewType.FREE_MARKER);
        routes.setBaseViewPath("/");
        routes.add("/login", LoginController.class);
        routes.add("/regsist", RegController.class);
        routes.add("/detial", ShowDetial.class);
        routes.add("/showCategory", Maincontroller.class);



    }

    @Override
    public void configEngine(Engine engine) {

    }

    @Override
    public void configPlugin(Plugins me) {
        loadPropertyFile("myconfig.properties");
        DruidPlugin dp = new DruidPlugin(getProperty("jdbcUrl"),
                getProperty("user"), getProperty("password"));
        me.add(dp);
        ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
        me.add(arp);
       arp.addMapping("user",model.User.class);
       arp.addMapping("post",model.Post.class);
       arp.addMapping("topic",model.Topic.class);
       arp.addMapping("category",model.Topic.class);

    }

    @Override
    public void configInterceptor(Interceptors interceptors) {

    }

    @Override
    public void configHandler(Handlers handlers) {

    }
    public static void main(String[] args){
        JFinal.start("src/main/webapp",8080,"/");
    }
}
